package com.example.child_protection.controller;

import com.example.child_protection.dto.base.BaseResponseDTO;
import com.example.child_protection.dto.request.SimpleIdRequestDTO;
import com.example.child_protection.dto.request.add.SystemMenuButtonInsertRequestDTO;
import com.example.child_protection.dto.request.find.CheckCodeRequestDTO;
import com.example.child_protection.dto.request.find.SystemMenuButtonRequestDTO;
import com.example.child_protection.dto.request.update.SystemMenuButtonUpdateRequestDTO;
import com.example.child_protection.dto.response.CheckCodeResponseDTO;
import com.example.child_protection.dto.response.SystemMenuButtonListResponseDTO;
import com.example.child_protection.dto.response.SystemMenuButtonResponseDTO;
import com.example.child_protection.service.SystemMenuButtonManageService;
import com.example.child_protection.service.SystemMenuButtonQueryService;
import com.example.child_protection.util.ContentType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 菜单按钮管理控制层
 * @date 2018-11-2
 * @author Biz
 */
@RestController
@RequestMapping("systemMenuButton")
@Api(value = "/api-systemMenuButton", description = "菜单按钮管理")
public class SystemMenuButtonController extends BaseController {

    @Autowired
    public SystemMenuButtonManageService systemMenuButtonManageService;

    @Autowired
    public SystemMenuButtonQueryService systemMenuButtonQueryService;

    @ApiOperation(value ="查询菜单按钮", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/findId", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public SystemMenuButtonResponseDTO findId(SimpleIdRequestDTO requestDTO,HttpServletRequest request)throws Exception{
        SystemMenuButtonResponseDTO responseDTO = systemMenuButtonQueryService.findId(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="检测按钮CODE是否重复", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/checkCode", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public CheckCodeResponseDTO checkCode(CheckCodeRequestDTO requestDTO, HttpServletRequest request)throws Exception{
        CheckCodeResponseDTO responseDTO = systemMenuButtonQueryService.checkCode(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="查询菜单按钮列表", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/findList", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public SystemMenuButtonListResponseDTO findList(SystemMenuButtonRequestDTO requestDTO, HttpServletRequest request)throws Exception{
        SystemMenuButtonListResponseDTO responseDTO = systemMenuButtonQueryService.findList(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="添加菜单按钮", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/insert", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public BaseResponseDTO insert(SystemMenuButtonInsertRequestDTO requestDTO)throws Exception{
        requestDTO.setCreatePersonId(this.getLoginUserId());
        requestDTO.setLastUpdatePersonId(this.getLoginUserId());
        BaseResponseDTO responseDTO = systemMenuButtonManageService.insert(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="修改菜单按钮", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/update", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public BaseResponseDTO update(SystemMenuButtonUpdateRequestDTO requestDTO)throws Exception{
        requestDTO.setLastUpdatePersonId(this.getLoginUserId());
        BaseResponseDTO responseDTO = systemMenuButtonManageService.update(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="删除菜单按钮", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/delete", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public BaseResponseDTO delete(SimpleIdRequestDTO requestDTO)throws Exception{
        requestDTO.setLastUpdatePersonId(this.getLoginUserId());
        BaseResponseDTO responseDTO = systemMenuButtonManageService.delete(requestDTO);
        return responseDTO;
    }

}
